<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        window.onload=function fx(){
        var n,a,flag;
        var sum,str;
        n=4;a=3;sum=0;str=String(a);flag=n;
                
             
         
            sum+=Number(str)
            console.log(str);
             
        
            for(;n>1;--n)
            {
            
                for(;flag>1;--flag)
                {
                    str+=String(a);
                    console.log(str+" ")
                    sum+=Number(str)
                }  
            }
               
            console.log("以上数字相加sum为："+ sum);
           
         }   
    </script>

</body>
</html>